package com.ctvit.sjk.knowledge.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctvit.sjk.knowledge.app.mapper.TabAppChatRecordMapper;
import com.ctvit.sjk.knowledge.app.pojo.domain.TabAppChatRecord;
import com.ctvit.sjk.knowledge.app.pojo.dto.AppChatRecordVoteDTO;
import com.ctvit.sjk.knowledge.app.service.ITabAppChatRecordService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * 应用聊天记录Service业务层处理
 *
 * @author heyingcheng
 * @date 2025/3/22
 */
@Service
public class TabAppChatRecordServiceImpl extends ServiceImpl<TabAppChatRecordMapper, TabAppChatRecord> implements ITabAppChatRecordService {

    @Override
    public boolean vote(String appId, String chatId, String recordId, AppChatRecordVoteDTO dto, String userId) {
        LambdaUpdateWrapper<TabAppChatRecord> wrapper = new LambdaUpdateWrapper<>();
        wrapper.set(TabAppChatRecord::getVoteStatus, dto.getVoteStatus());
        wrapper.set(TabAppChatRecord::getUpdateTime, LocalDateTime.now());
        wrapper.eq(TabAppChatRecord::getRecordId, recordId);
        return update(wrapper);
    }

}
